<div class="layer-wraper"></div>
<div class="layermain">
    <div class="blocktb clearfix">
        <a href="javascript:void(0);" class="text-normal pull-left cancel">取消</a>
        <a href="javascript:void(0);" class="text-green pull-right sure">确认</a></div>
    <if condition="!$roomService[1] and !$roomService[2] and !$roomService[3]">
        <div class="title text-gray" style="text-align: center">该会议室暂无服务</div>
        <else />
        <if condition="$roomService[1]">
            <div class="title text-gray">设备设施</div>
            <div class="category clearfix facility">
                <foreach name="roomService[1]" item="vo">
                    <div class="category-list pull-left">{BEESCRM:$vo.device_name}
                        <div class="quantity pull-right">
                            <span class="iconfont icon-jian change-num-btn" data-status="sub"></span>
                            <input class="count" type="number" value="0" data-device_name="{BEESCRM:$vo.device_name}" data-status="input" autocomplete="on" data-device_id="{BEESCRM:$vo.device_id}" data-max_num="{BEESCRM:$vo.max_num}">
                            <span class="iconfont icon-plus-copy change-num-btn" data-status="plus"></span>
                        </div>
                    </div>
                </foreach>
            </div>
        </if>

        <if condition="$roomService[2]">
            <div class="title text-gray">会务服务</div>
            <div class="category clearfix property">
                <foreach name="roomService[2]" item="vo">
                    <div class="category-list pull-left">{BEESCRM:$vo.device_name}
                        <div class="quantity pull-right">
                            <span class="iconfont icon-jian change-num-btn" data-status="sub"></span>
                            <input class="count" type="number" value="0" data-device_name="{BEESCRM:$vo.device_name}" data-status="input" autocomplete="on" data-device_id="{BEESCRM:$vo.device_id}" data-max_num="{BEESCRM:$vo.max_num}">
                            <span class="iconfont icon-plus-copy change-num-btn" data-status="plus"></span>
                        </div>
                    </div>
                </foreach>
            </div>
        </if>
        <if condition="$roomService[3]">
            <div class="title text-gray">其他（桌椅、绿植）</div>
            <div class="category clearfix other">
                <foreach name="roomService[3]" item="vo">
                    <div class="category-list pull-left">{BEESCRM:$vo.device_name}
                        <div class="quantity pull-right">
                            <span class="iconfont icon-jian change-num-btn" data-status="sub"></span>
                            <input class="count" type="number" value="0" data-device_name="{BEESCRM:$vo.device_name}" data-status="input" autocomplete="on" data-device_id="{BEESCRM:$vo.device_id}" data-max_num="{BEESCRM:$vo.max_num}">
                            <span class="iconfont icon-plus-copy change-num-btn" data-status="plus"></span>
                        </div>
                    </div>
                </foreach>
            </div>
        </if>
    </if>
    <div class="title text-gray" style="border-bottom: none;">备注</div>
    <textarea style="width: 100%;min-height: 120px;border: 1px solid #e6e6e6;margin-top: 6px;border-radius: 4px;padding: 10px;" name="remarkText" id="remarkText" onkeyup="javascript:checkWord(this);" onmousedown="javascript:checkWord(this);"></textarea>
    <div class="title text-gray" style="border-bottom: none;">还可以输入<span style="font-family: Georgia; font-size: 26px;" id="wordCheck">40</span>个字</div>
</div>
<input type="hidden" name="panelType" id="panelType" value="{BEESCRM:$panelType}" />
<input type="hidden" name="date" id="date" value="{BEESCRM:$date}" />
<script type="text/javascript" src="/assets/public/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="/assets/meeting/js/checkword.js"></script>
<script>
    $(document).on('click','.cancel',function() { //取消
        $(".layer-wraper").hide();
        $(".layermain").hide();
    })

    $(document).on('click','.sure',function() { //确定

        var facility = [];
        var property = [];
        var other = [];

        var flag = 0;
        var name = '';
        $(".other .count").each(function() {
            if($(this).val() != 0) {
                if($(this).data('max_num') != -1 && $(this).val() > $(this).data('max_num') || $(this).val() <0 || parseInt($(this).val()) != $(this).val()) {
                    name = $(this).data('device_name');
                    flag = 1;return false;
                }
                other.push([$(this).data('device_name'),$(this).val()]);
            }
        })

        $(".property .count").each(function() {
            if($(this).val() != 0) {
                if($(this).data('max_num') != -1 && $(this).val() > $(this).data('max_num') || $(this).val() <0 || parseInt($(this).val()) != $(this).val()) {
                    name = $(this).data('device_name');
                    flag = 1;return false;
                }
                property.push([$(this).data('device_name'),$(this).val()]);
            }
        })

        $(".facility .count").each(function() {
            if($(this).val() != 0) {
                if($(this).data('max_num') != -1 && $(this).val() > $(this).data('max_num') || $(this).val() <0 || parseInt($(this).val()) != $(this).val()) {
                    name = $(this).data('device_name');
                    flag = 1;return false;
                }
                facility.push([$(this).data('device_name'),$(this).val()]);
            }
        })

        if(flag == 1) {
            fm.alert(name + '超过最大值或者数量不是正整数');return false;
        }

        if(facility.length != 0) {
            var facilityHtml = '';
            $.each(facility,function() {
                facilityHtml = facilityHtml + $(this)[0] + '*' + $(this)[1] + '&nbsp;&nbsp;|&nbsp;&nbsp;';
            })
            $('.facility .flex-item').html(facilityHtml);
            $(".facility").removeClass('hide');
        }

        console.log(property);
        if(property.length != 0) {
            var propertyHtml = '';
            $.each(property,function() {
                propertyHtml = propertyHtml + $(this)[0] + '*' + $(this)[1] + '&nbsp;&nbsp;|&nbsp;&nbsp;';
            })
            $('.property .flex-item').html(propertyHtml);
            $(".property").removeClass('hide');
        }

        if(other.length != 0) {
            var otherHtml = '';
            $.each(other,function() {
                otherHtml = otherHtml + $(this)[0] + '*' + $(this)[1] + '&nbsp;&nbsp;|&nbsp;&nbsp;';
            })
            $('.other .flex-item').html(otherHtml);
            $(".other").removeClass('hide');
        }
        $(".layer-wraper").hide();
        $(".layermain").hide();
    })
</script>